//
//  FirstViewController.swift
//  Demo
//
//  Created by wyatt on 15/3/9.
//  Copyright (c) 2015年 Wanqing Wang. All rights reserved.
//

import UIKit

class FirstViewController: UIViewController, SecondViewControllerDelegate {
    
    @IBOutlet weak var label: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    // 4
    func changeLabelContent(controller: SecondViewController, content str: String) {
        label.text = str
        dismissViewControllerAnimated(true, completion: nil)
    }
    
    // 5
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        var secondView = SecondViewController()
        if segue.identifier == "next" {
            secondView = segue.destinationViewController as SecondViewController
            secondView.delegate = self
        }
    }
}
